package com.sskj.level.ui.activity;


import android.graphics.Color;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.sskj.level.R;
import com.sskj.level.R2;
import com.sskj.level.presenter.SlideActivityPresenter;
import com.sskj.common.util.ClickUtil;
import com.sskj.lib.Constans;
import com.sskj.lib.RConfig;
import com.sskj.lib.base.BaseActivity;

import butterknife.BindView;

@Route(path = RConfig.LEVEL_SLIDE)//侧滑页面
public class SlideActivity extends BaseActivity<SlideActivityPresenter> {
    @BindView(R2.id.ivClose)
    ImageView ivClose;
    @BindView(R2.id.frameLayout)
    FrameLayout frameLayout;
    @BindView(R2.id.llRoot)
    LinearLayout llRoot;

    @Override
    protected int getLayoutResId() {
        return R.layout.level_activity_slide;
    }

    @Override
    public SlideActivityPresenter getPresenter() {
        return new SlideActivityPresenter();
    }

    @Override
    public boolean getOrientation() {
        return false;
    }

    @Override
    protected void initView() {
        overridePendingTransition(R.anim.level_slide_left_in, R.anim.level_slide_no_move);
        getWindow().setLayout(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);//需要添加的语句
        ClickUtil.click(ivClose, () -> {
            llRoot.setBackgroundColor(Color.TRANSPARENT);
            finish();
        });
        Fragment fragment = (Fragment) ARouter.getInstance().build(RConfig.APP_FRAGMENT_COIN_LIST).withBoolean(Constans.IS_SLIDE,true).navigation();
        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.add(R.id.frameLayout, fragment);
        fragmentTransaction.show(fragment);
        fragmentTransaction.commitNow();
    }

    @Override
    public void finish() {
        super.finish();
        //注释掉activity本身的过渡动画
        overridePendingTransition(0, R.anim.level_slide_left_out);
    }
}
